import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-11-26
 * Time: 17:31
 */

//字典服务器
public class UdpDicServer extends UdpEchoServer {
    Map<String, String> map = new HashMap<>();
    public UdpDicServer(int port) throws SocketException {
        super(port);
        map.put("cat","小猫");
        map.put("dog","小狗");
        map.put("fuck","窝草");
    }

    @Override
    public String process (String request) {
        return map.getOrDefault(request,"??不会……");
    }
    public static void main(String[] args) throws IOException {
        UdpDicServer serve = new UdpDicServer(9090);
        serve.start();
    }
}
